package com.comcast.core.eeg.types;

import java.io.ObjectStreamException;

import java.io.Serializable;

/**
 * 
 * Used to overcome the issue related to Enum with IIOP.
 * 
 * @author thuang000c
 *
 * @param <E>
 */
public class EnumHolder<E extends Enum<E>> implements Serializable {

    private static final long serialVersionUID = 1L;

    private Class<E> clazz;

    private String value;

    public EnumHolder(E enumLiteral) {
        clazz = enumLiteral.getDeclaringClass();
        value = enumLiteral.name();
    }

    private Object readResolve() throws ObjectStreamException {
        return Enum.valueOf(clazz, value);
    }
}
